package com.ybliang.plat.serviceapp.common.exception;

/**
 * 定义业务异常
 * @author liangyb1
 */
public class BusinessException extends RuntimeException {

	private static final long serialVersionUID = -8666065744483726501L;

	public int code;

	public String message;

	public BusinessException() {
		super();
	}

	public BusinessException(int code, String message) {
		super(String.format("%d -> %s", code, message));
		this.code = code;
		this.message = message;
	}

	public BusinessException(Error error) {
		super(String.format("%d -> %s", error.getCode(), error.getMessage()));
		this.code = error.getCode();
		this.message = error.getMessage();
	}

	public BusinessException(Error error, String exMessage) {
		super(String.format("%d -> %s", error.getCode(), exMessage));
		this.code = error.getCode();
		this.message = exMessage;
	}

	public BusinessException(int code, String message, Throwable cause) {
		super(String.format("%d -> %s", code, message), cause);
		this.code = code;
		this.message = message;
	}
}
